package min3d.sampleProject1;
import android.view.MotionEvent;
import android.view.View;

public class ViewListener implements View.OnTouchListener{
	MyActivity ra;
	
	/**
	 * Constructor
	 * @param MyActivity 	A Handle to the activity object
	 */
	public ViewListener(MyActivity ra){
		this.ra = ra;
	}
	
	/**
	 * Handles the touch events and sets touchDown accordingly
	 * Saves the MyActivity handle and instantiates the tracker. 
	 * @param  View 			The view of the current activity.
	 * @param  MotionEvent		The motion event that was created by the touch.
	 * @return boolean			True if event handled, false otherwise.
	 */
	public boolean onTouch(View v, MotionEvent event) {
		if(event.getAction() == MotionEvent.ACTION_DOWN){
			//Log.v("MOTION", "ACTION DOWN");
			ra.touchDown = true;
		}
		else if(event.getAction() == MotionEvent.ACTION_UP){
			//Log.v("MOTION", "ACTION UP");
			ra.touchDown = false;
		}
		else{
			//Log.v("MOTION", "ACTION: " + event.getAction());
		}
        return true;
	}
	
}